<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<div id="app">
    <h1>测试身体质量指数</h1>
    <input type="text" placeholder="请输入身高(米)" v-model="h">
    <input type="text" placeholder="请输入体重(公斤)" v-model="w">
    <input type="button" value="计算" @click="fn()">
    <h1>测试结果:{{result}}</h1>
</div>
</body>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v =  new Vue({
        el: '#app',
        data: function() {
            return {
                h:"",//身高
                w:"",//体重
                result:""//计算结果
            }
        },
        methods:{
            fn(){
                //发送get请求，/bmi?h=身高&w=体重
                axios.get("/bmi?h="+v.h+"&w="+v.w).then(function (info) {
                    v.result = info.data
                })
            }
        }
    })
</script>
</html>